﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using Project.Common;
using CNRegex.Web.Controllers;

namespace CNRegex.Web.Base
{
	public class UserHomeRouteConstraint : IRouteConstraint
	{
		private static List<string> systemControllers = new List<string>()
		{
			"AccountBack",
			"Account",
			"HomeBack",
			"Home",
			"AdminRegexCategory",
			"RegexHome",
			"AccountHomePage",
			"Regex",
			"RegexTutorial",
			"AdminRegexTutorial",
			"AdminRegexTutorialCatalog",
			"AdminRegexBlogCatalog",
			"DesignPattern",
			"Blog",
			"Upload",
			"Test"
		};
		public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
		{
			foreach (var item in systemControllers)
			{
				if (values["name"].ToString().Equals(item,StringComparison.OrdinalIgnoreCase))
					return false;
			}
			return true;
		}
	}
}